package de.hft.st.algodat.ctt.algo;

import java.util.Random;

public class EA {

	private int numberOfCourses;
	private int numberOfTimeslots;
	private final int RANDOM_MAX = 1000;
	private int[] cPri;
	private int[] tsPri;

	public EA(int numberOfCourses, int numberOfTimeslots) {
		this.numberOfCourses = numberOfCourses;
		this.numberOfTimeslots = numberOfTimeslots;
		this.generateRandomCoursesPri(this.numberOfCourses + 1);
		this.generateRandomTimeslotsPri(this.numberOfTimeslots + 1);
	}

	public void increaseCoursePri(int offset, int increase) {
		this.cPri[offset] += increase;
	}

	public void increaseTSPri(int offset) {
		this.tsPri[offset] += 10;
	}

	public void decreaseCoursePri(int offset, int decrease) {
		this.cPri[offset] -= decrease;
	}

	public void decreaseTSPri(int offset, int decrease) {
		this.tsPri[offset] -= decrease;
	}

	public int[] getCPri() {
		return cPri;
	}

	public int[] getTSPri() {
		return tsPri;
	}

	public void generateRandomCoursesPri(int size) {
		cPri = new int[size];
		Random generator = new Random();
		for (int i = 1; i < cPri.length; i++) {
			cPri[i] = generator.nextInt(RANDOM_MAX);
		}
		// for (int i = 1; i < cPri.length; i++) {
		// cPri[i] = i;
		// }
	}

	public void generateRandomTimeslotsPri(int size) {
		tsPri = new int[size];
		Random generator = new Random();
		for (int i = 1; i < tsPri.length; i++) {
			tsPri[i] = generator.nextInt(RANDOM_MAX);
		}
		// for (int i = 1; i < tsPri.length; i++) {
		// tsPri[i] = i;
		// }
	}

	public int[] mutate(int[] in) {
		int[] out = new int[in.length];
		Random generator = new Random();
		for (int i = 1; i < out.length; i++) {
			out[i] = (generator.nextInt(RANDOM_MAX) * in[i]) % RANDOM_MAX;
		}
		return out;
	}

}
